#include "sort.h"

void TestOP()
{
	 
	 const int N = 100000;
	 int* a1 = (int*)malloc(sizeof(int)*N);
	 int* a2 = (int*)malloc(sizeof(int)*N);
	 int* a3 = (int*)malloc(sizeof(int)*N);
	 int* a4 = (int*)malloc(sizeof(int)*N);
	 int* a5 = (int*)malloc(sizeof(int)*N);
	 int* a6 = (int*)malloc(sizeof(int)*N);
	 int i = 0;
	 int begin1,end1;
	 int begin2,end2;
	 int begin3,end3;
	 int begin4,end4;
	 int begin5,end5;
	 int begin6,end6;
	 srand(time(0));

	 for (i = 0; i < N; ++i)
	 {
	 a1[i] = rand();
	 a2[i] = a1[i];
	 a3[i] = a1[i];
	 a4[i] = a1[i];
	 a5[i] = a1[i];
	 a6[i] = a1[i];
	 }
	 begin1 = clock();
	 Insert_sort(a1, N);
	 end1 = clock();

	 begin2 = clock();
	 ShellSort(a2, N);
	 end2 = clock();

	 begin3 = clock();
	 SelecSort(a3, N);
	 end3 = clock();

	 begin4 = clock();
	 HeapSort(a4, N);
	 end4 = clock();

	 begin5 = clock();
	 QuickSort(a5, 0, N-1);
	 end5 = clock();

	 //
	 //begin5 = clock();
	 //StackQuickSort(a5, 0, N-1);
	 //end5 = clock();

	 //begin6 = clock();
	 //MergeSort(a6, N);
	 //end6 = clock();

	 printf("InsertSort:%d\n", end1 - begin1);
	 printf("ShellSort:%d\n", end2 - begin2);
	 printf("SelectSort:%d\n", end3 - begin3);
	 printf("HeapSort:%d\n", end4 - begin4);
	 printf("QuickSort:%d\n", end5 - begin5);
	 //printf("MergeSort:%d\n", end6 - begin6);
	 free(a1);
	 free(a2);
	 free(a3);
	 free(a4);
	 free(a5);
	 free(a6);
}

int main()
{
	TesInsertSort();
	TestOP();
	return 0;
}